package com.example.figurehecheng.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.figurehecheng.domain.entity.Orders;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDateTime;

import org.apache.ibatis.annotations.Param;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 宇科工作室
 * @since 2024-10-18
 */
public interface OrderMapper extends BaseMapper<Orders> {

    /**
     * 获取今天，这周，这个月，今年收入总金额
     * @return
     */
    @Select("select SUM(price) from orders where order_time >= #{orderTime} and merchant_id = #{merchantId} and statue = #{statue}")
    BigDecimal getTurnover(@Param("orderTime")LocalDateTime localDateTime,
                           @Param("merchantId") Long currentId,
                           @Param("statue") Integer completeTheOrder);



    @Select("SELECT SUM(price) FROM `orders` WHERE merchant_id =  #{merchantId} AND statue = #{statue} AND order_time BETWEEN #{orderTime} AND #{orderTime1}")
    BigDecimal getTurnoverStatistics(@Param("orderTime") LocalDateTime firstDayTime,
                                     @Param("orderTime1") LocalDateTime lastDayTime,
                                     @Param("merchantId") Long currentId,
                                     @Param("statue") Integer completeTheOrder);
}
